import request from '@/utils/request'

// 获取文章列表
export const getArticleListApi = (params) => {
    return request({
        url: '/articles',
        method: 'get',
        params,
    })
}

// 查询文章详情
export const getArticleInfoApi = (id) => {
    return request({
        url: '/articles/' + id,
        method: 'get',
    })
}

// 添加文章
export const addArticleApi = (data) => {
    return request({
        url: '/articles',
        method: 'post',
        data,
    })
}

// 修改文章
export const editArticleApi = (data) => {
    return request({
        url: '/articles/' + data.id,
        method: 'put',
        data,
    })
}

// 删除文章
export const delArticleInfoApi = (id) => {
    return request({
        url: '/articles/' + id,
        method: 'delete',
    })
}

// 设置文章状态
export const editArticleStateApi = (data) => {
    return request({
        url: '/articles/' + data.id + '/' + data.state,
        method: 'post',
    })
}